import request from '@/utils/request';

/**
 * 分页查询字典信息
 * @param {*} pageParam
 */
export const page = pageParam => {
  return request({
    url: '/admin/dict/page',
    data: pageParam,
    method: 'post'
  });
};

/**
 * 新增字典
 * @param {*} dict
 */
export const save = dict => {
  return request({
    url: '/admin/dict/save',
    data: dict,
    method: 'post'
  });
};

/**
 * 更新字典信息
 * @param {} dict
 */
export const update = dict => {
  return request({
    url: '/admin/dict/update',
    data: dict,
    method: 'post'
  });
};

/**
 * 获取字典详情
 * @param {*} id
 */
export const get = param => {
  return request({
    url: '/admin/dict/get',
    data: param,
    method: 'post'
  });
};

/**
 * 删除字典信息
 * @param {*} id
 */
export const remove = id => {
  return request({
    url: '/admin/dict/del',
    data: {
      id: id
    },
    method: 'post'
  });
};

/**
 * 验证字典编码
 * @param {*} code
 */
export const verifyDictCode = param => {
  return request({
    url: '/admin/dict/check',
    data: param,
    method: 'post',
    async: false
  });
};
/**
 * 获取字典
 * @param {*} code
 */
export const getDict = param => {
  return request({
    url: '/admin/dict/getSonDictByPCode',
    data: param,
    method: 'post',
    async: false
  });
};
/**
 * 获取多个字典
 * @param {*} code
 */
export const getDicts = param => {
  return request({
    url: '/admin/dict/getSonDictByPCodes',
    data: param,
    method: 'post'
  });
};
